package udpdemo4;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-08-09
 * Time: 0:39
 */
public class ServerDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket=new DatagramSocket(1000);
        byte[] bytes=new byte[1024];
        DatagramPacket packet=new DatagramPacket(bytes, bytes.length);
        socket.receive(packet);
        byte[] data= packet.getData();
        int length= packet.getLength();
        System.out.println(new String(data,0,length));
        socket.close();
    }
}
